<?php
/**
 * Created by PhpStorm.
 * User: function
 * Date: 2018-04-15
 * Time: 15:09
 */

namespace app\common\logic;
use app\common\logic\Logic;
use app\common\model\Category;
use app\common\model\Type;
use app\common\model\CatType;
class CatTypeLogic extends Logic
{
    protected $modelClass = 'app\common\model\CatType';
    protected $column = 'id,category_id,type_id,type_title';
    
    public function clear($catid=null,$typeId=null){
       
        //不能同时为null
        if(!$catid&&!$typeId){
            return false;
        }
        if($typeId){
            $filter['type_id'] = $typeId;
        }
        
        if($catid){
            $filter['category_id'] = $catid;
        }
        
        
        
    
        $list = CatType::where($filter)->select();
        
        foreach ($list as $item){
            $item->delete();
        }
        return true;
    }
    
}